package com.jiayang.hhotel.app;

import android.app.Application;
import android.content.Context;

import com.jiayang.hhotel.R;
import com.jiayang.hhotel.bean.LoginModel;
import com.jiayang.hhotel.util.DataKeeper;
import com.jiayang.hhotel.util.ImageLoaderUtil;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import cn.droidlover.xdroidmvp.net.NetError;
import cn.droidlover.xdroidmvp.net.NetProvider;
import cn.droidlover.xdroidmvp.net.RequestHandler;
import cn.droidlover.xdroidmvp.net.XApi;
import okhttp3.CookieJar;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;

/**
 * Created by Administrator on 2017/5/2 0002.
 */

public class App extends Application {
    private static Context context;
    public static LoginModel model;
    public static Map<String,Integer> most_issueMap=new HashMap<>();//权限代码对应的图片res

    @Override
    public void onCreate() {
        super.onCreate();
        context = this;
        ImageLoaderUtil.init(context);
        DataKeeper.init(context);
        initMostIssueList();
        XApi.registerProvider(new NetProvider() {

            @Override
            public Interceptor[] configInterceptors() {
                return new Interceptor[0];
            }

            @Override
            public void configHttps(OkHttpClient.Builder builder) {

            }

            @Override
            public CookieJar configCookie() {
                return null;
            }

            @Override
            public RequestHandler configHandler() {
                return null;
            }

            @Override
            public long configConnectTimeoutMills() {
                return 0;
            }

            @Override
            public long configReadTimeoutMills() {
                return 0;
            }

            @Override
            public boolean configLogEnable() {
                return true;
            }

            @Override
            public boolean handleError(NetError error) {
                return false;
            }
        });
    }

    public static Context getContext() {
        return context;
    }

    /**
     * 启动时初始化首页权限list
     */
    private void initMostIssueList(){
        most_issueMap.put("020801", R.mipmap.dingdanchaxun);
        most_issueMap.put("020803",R.mipmap.dingcanchaxun);
        most_issueMap.put("1402",R.mipmap.kezufang);
        most_issueMap.put("1401",R.mipmap.zuixintongji);
        most_issueMap.put("0301",R.mipmap.xianzhuchaxun);
        most_issueMap.put("0401",R.mipmap.chafang);
        most_issueMap.put("0402",R.mipmap.qingjie);
        most_issueMap.put("0411",R.mipmap.teshufangtai);
        most_issueMap.put("06",R.mipmap.caiwuchuli);
        most_issueMap.put("16",R.mipmap.yeshen);
        most_issueMap.put("0105",R.mipmap.tongjifenxi);
        most_issueMap.put("0106",R.mipmap.xieyikehu);
        most_issueMap.put("15",R.mipmap.xitongshezhi);
    }
}
